package com.platform.controller.backend;

import com.github.pagehelper.PageInfo;
import com.platform.base.BaseController;
import com.platform.common.Const;
import com.platform.common.ServerResponse;
import com.platform.util.StringUtil;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.Map;

@RestController
@RequestMapping("/consumablesController/")
@CrossOrigin(origins = Const.REQUESTURL,maxAge = 3600,allowCredentials = "true")
public class ConsumablesController extends BaseController {

    /**
     * 耗材价格条件查询
     * @param paramMap
     * @param request
     * @return
     */
    @GetMapping("selectByParamMap.do")
    public ServerResponse<PageInfo> selectByParamMap(@RequestParam Map paramMap, HttpServletRequest request){
        return iConsumablesService.selectByParamMap(paramMap,request);
    }

    /**
     * 数据导入
     * @param paramMap 附件访问地址
     * @return
     */
    @PostMapping("importData.do")
    public ServerResponse<String> importData(@RequestParam Map paramMap, HttpServletRequest request) {
        return iConsumablesService.importData(StringUtil.valueOfString(paramMap.get("fileUrl")),request);
    }

    /**
     * 根据ID查询详情
     * @param id
     * @param request
     * @return
     */
    @GetMapping("selectById.do")
    public ServerResponse<Map> selectById(@RequestParam(value = "id") Integer id,
                                          HttpServletRequest request){
        return iConsumablesService.selectById(id,request);
    }
}
